﻿@if (false) 
{ 
    // Just use this script to enable jQuery intellisense in Visual Studio. Never render to real HTML.
    <script src="/Scripts/jquery-1.5.1-vsdoc.js" type="text/javascript"></script>
}

@using System.Text.RegularExpressions
@using ORM.Models
@model IList<Guide>
@{
    ViewBag.Title = "Approve Guides";
    ViewBag.MenuGroup = "Approval";
    ViewBag.MenuName = "ApproveGuides";
    ViewBag.PageHeader = "Approve Guides";
}

@(Html.Telerik().Grid(Model)
        .Name("Guides")
    .DataKeys(dataKeys => dataKeys.Add(c => c.Id))
    .Columns(columns =>
    {
         columns.Template(
            @<text>
                 <a class="view-guide" title="@item.Title">@item.Title</a>
                 <input type="hidden" value="@item.Id" class="id" />
            </text>).Width("350px").Title("Title");
         columns.Template(
                @<text>
                <a href="/admin/ManageUsers/Details/@item.PostedByUser.Id">@item.PostedByUser.Username</a>
                </text>
               ).Width("150px").Title("Posted By");
         columns.Bound(o => o.PostedDate).Format("{0:dd/MM/yyyy HH:mm}").Width("110px");
         columns.Template(
             @<text> 
                @Html.Partial("_EditButton", new ActionInfo("Approve", "ApproveGuide") { Id = item.Id })
                @Html.Partial("_EditButton", new ActionInfo("Disapprove", "DisApproveGuide") { Id = item.Id })
            </text>
         );
    })
                                            .Pageable(pager => pager.PageSize(AppConfigs.DefaultAdminGridPageSize))
                                            .Sortable()
                                            .Scrollable(scrolling => scrolling.Enabled(true).Height(350))
                                        )


@(Html.Telerik().Window()
        .Name("guide-details-window")
        .Title("Guide Details")
        .Content(
            @<text>
                <div id="guide-details"></div>
            </text>
        )
        .Width(700)
        .Height(700)
        .Scrollable(true)
        .Draggable(true)
        .Modal(true)
        .Visible(false)
)
<script type="text/javascript">
    $(document).ready(function () {
        
         $(".view-guide").click(function (e) {
            e.preventDefault();
            var id = $("~ .id", this).val();
            $("#guide-details").html("");
            $("#guide-details").load("@Url.Action("GuideDetails")", "id=" + id);
            $('#guide-details-window').data('tWindow').center().open();
        });

         $("#Approve").click(function (e) {
            if (!confirm("Are you sure you want to approve this guide?")) {
                return false;
            }
        });
        $("#Disapprove").click(function (e) {
            if (!confirm("Are you sure you want to disapprove this guide?")) {
                return false;
            }
        });
    });
</script>